package cn.edu.scau.cmi.luotiansheng_chapter9;

public class EncryptAndDecrypt {
	String encrypt(String sourceString,String password) {
		char []p=password.toCharArray();
		char []c=sourceString.toCharArray();
		int n=p.length;
		int m=c.length;
		
		for(int i=0;i<m;i++) {
			int mima=c[i]+p[i%n];
			c[i]=(char)mima;
		}
		return new String(c);
	}
	
	String Decrypt(String sourceString,String password) {
		char []p=password.toCharArray();
		char []c=sourceString.toCharArray();
		int n=p.length;
		int m=c.length;
		
		for(int i=0;i<m;i++) {
			int mima=c[i]-p[i%n];
			c[i]=(char)mima;
		}
		return new String(c);
	}
	
}
